package com.qiaoanju.back.domain.system;

import com.qiaoanju.domain.BaseModel;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;

/**
 * Created by eversec
 * on 2017/9/21.
 */
public class UserModel extends BaseModel implements UserDetails, Serializable {


    //用户组id
    private Integer group_id ;

    // 用户名
    private String user_name;

    // 密码
    private String password;

    // 真实姓名
    private String real_name;

    // 手机
    private String phone;

    // 公司或单位
    private String company;

    // 电子邮件
    private String email;

    // 是否可用
    private Integer is_locked = 1;

    // 激活码
    private String activation_code;


    // 重置码
    private String reset_code;

    /*
     * 用户类型: 1：平台管理员 2：团队管理员 3：团队用户
     */
    private Integer user_type;

    /*
     * 用户状态 1：禁用(未激活) 2：启用（激活）
     */
    private Integer user_state = 1;


    /*
     * 是否黑名单    1：白名单   2：黑名单
     */
    private Integer abolished = 1;


    //用户代号
    private String usermark;

    //PDA imei信息
    private String imei;

    public Integer getGroup_id() {
        return group_id;
    }

    public void setGroup_id(Integer group_id) {
        this.group_id = group_id;
    }

    public String getUser_name() {
        return user_name;
    }

    public void setUser_name(String user_name) {
        this.user_name = user_name;
    }

    //重写UserDetails方法

    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    public String getPassword() {
        return password;
    }

    public String getUsername() {
        return user_name;
    }

    /**
     * 登录失败次数
     */
    private int failedLoginAttempts;

    /**
     * 权限
     */
    private Collection<? extends GrantedAuthority> authorities;
    /**
     * 账号未过期
     */
    private boolean accountNonExpired = true;
    /**
     * 账号未锁定
     */
    private boolean accountNonLocked = true;
    /**
     * 证书未过期
     */
    private boolean credentialsNonExpired = true;
    /**
     * 是否启用
     */
    private boolean enabled = true;
    public boolean isAccountNonExpired() {
        return accountNonLocked;
    }

    public boolean isAccountNonLocked() {
        return accountNonLocked;
    }

    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
        this.authorities = authorities;
    }
    public void setPassword(String password) {
        this.password = password;
    }

    public UserModel(String username, String password,Collection<? extends GrantedAuthority> authorities) {

        this.user_name = username ;
        this.password = password ;
        this.authorities = authorities ;
    }

    public String getReal_name() {
        return real_name;
    }

    public void setReal_name(String real_name) {
        this.real_name = real_name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getIs_locked() {
        return is_locked;
    }

    public void setIs_locked(Integer Is_locked) {
        this.is_locked = is_locked;
    }

    public String getActivation_code() {
        return activation_code;
    }

    public void setActivation_code(String activation_code) {
        this.activation_code = activation_code;
    }

    public String getReset_code() {
        return reset_code;
    }

    public void setReset_code(String reset_code) {
        this.reset_code = reset_code;
    }

    public Integer getUser_type() {
        return user_type;
    }

    public void setUser_type(Integer user_type) {
        this.user_type = user_type;
    }

    public Integer getUser_state() {
        return user_state;
    }

    public void setUser_state(Integer user_state) {
        this.user_state = user_state;
    }

    public Integer getAbolished() {
        return abolished;
    }

    public void setAbolished(Integer abolished) {
        this.abolished = abolished;
    }

    public String getUsermark() {
        return usermark;
    }

    public void setUsermark(String usermark) {
        this.usermark = usermark;
    }

    public String getImei() {
        return imei;
    }

    public void setImei(String imei) {
        this.imei = imei;
    }

    public UserModel() {
        super();
    }


    /*    //角色
    List<RoleModel> rolePackage ;

    //菜单
    List<MenuModel> menuPackage ;


    public List<RoleModel> getRolePackage() {
        return rolePackage;
    }

    public void setRolePackage(List<RoleModel> rolePackage) {
        this.rolePackage = rolePackage;
    }

    public List<MenuModel> getMenuPackage() {
        return menuPackage;
    }

    public void setMenuPackage(List<MenuModel> menuPackage) {
        this.menuPackage = menuPackage;
    }*/

}
